;(function($) {
	$.extend({
		getDate : function(){ 
			return options = {
				popupStyle: "", 
				title: "提示", 
				titleClass: "",
				msg: "你确定吗？",
				btnYesText: "确&nbsp;定",
				btnYesClass: "",
				btnNoText: "取&nbsp;消",
				btnNoClass: "",
				noBtnHide:''
			};
		},
		setDate : function(options) {	//设置弹框的效果样式
			return $.extend(this.getDate(), options);
		},
		closePop : function() {			//关闭弹框、遮罩层
			$("#popup-alert-overlay").remove();
			$("#popup-alert-panel").remove();
		},
		getIE: function() {  //判断是不是IE9以下
			if(navigator.userAgent.indexOf("MSIE")>0){   
			    if(navigator.userAgent.indexOf("MSIE 6.0")>0){   
			       return true;    
			    }   
			    else if(navigator.userAgent.indexOf("MSIE 7.0")>0){  
			       return true;   
			    }   
			    else if(navigator.userAgent.indexOf("MSIE 9.0")>0 && !window.innerWidth){//这里是重点，你懂的
			       return true; 
			    }   
			    else if(navigator.userAgent.indexOf("MSIE 9.0")>0){  
			       return true;
			    }   
		    }else{
		    	return false;
		    }
		},
		animateIE : function(){		//	IE9以下，弹框的动画效果
			/*$('.popup-alert-overlay').animate({opacity:.5}, 500);*/
			$('.popup-alert-panel').css({marginTop:'-140px'}).animate({marginTop:'-110px'}, 500);
		},
		enameConfirm : function(options, callback) {  //调用弹框主事件
			var that, panel, overlay, iepanel, docHeight, option;
			
			if(typeof options === 'function'){
				callback = options;
				options = '';
			}
			that = this;
			option = that.setDate(options);

			switch(option.popupStyle){
			 	case 'success':
			 		option.popupStyle = 'prompt-suc';
			 		break;
			 	case 'failure':
			 		option.popupStyle = 'prompt-fail';
			 		break;
			 	default:
			 		break;
			}
		   option.noBtnHide = option.noBtnHide ? '':'<input id="enameNoBtn" type="button" class="alert-btn alert-btn-no ' + option.btnNoClass + '" value='+ option.btnNoText +' />' ;
		 	panel = "<h3 class='popup-alert-title " + option.titleClass + "'>"+ option.title +"</h3>"
					  + "<p class='prompt " + option.popupStyle + "'> "+ option.msg +"</p>"
				      + "<div class='browser'>"
				      + '<input id="enameYesBtn" type="button" class="alert-btn alert-btn-yes ' + option.btnYesClass + '" value='+ option.btnYesText +' />'+ option.noBtnHide ;
				      + "</div>"; 

			overlay = $("<div id='popup-alert-overlay' class='popup-alert-overlay'></div>");
			iepanel = $("<div id='popup-alert-panel' class='popup-alert-panel " + option.popupStyle + "'>"+ panel +"</div>");

			$('body').append(overlay).append(iepanel);

			if(that.getIE){
				that.animateIE();
			}

			$("#enameYesBtn").unbind("click").click(function () {
				that.closePop();
				callback(true)
			});
			$("#enameNoBtn").unbind("click").click(function () {
				that.closePop();
				callback(false)
			});
		}
	})
})(jQuery);
